<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="../base.jsp"%>
<!DOCTYPE html>
<html>

<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>数据 - AdminLTE2定制版</title>
    <meta name="description" content="AdminLTE2定制版">
    <meta name="keywords" content="AdminLTE2定制版">
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <!-- 页面meta /-->
</head>
<body>
<div id="frameContent" class="content-wrapper" style="margin-left:0px;">
    <section class="content-header">
        <h1>
            统计分析
            <small>每人签订购销合同数统计</small>
        </h1>
    </section>
    <section class="content">
        <div class="box box-primary">
            <div id="main" style="width: 700px;height:700px;"></div>
        </div>
    </section>
</div>
</body>

<script src="../plugins/jQuery/jquery-2.2.3.min.js"></script>
<script src="../../plugins/echarts/echarts.min.js"></script>
<script type="text/javascript">
    // 基于准备好的dom，初始化echarts实例
    var myChart = echarts.init(document.getElementById('main'));

    $.get('/stat/contractCharts.do').done(function (data) {

        let titles = [];
        let values = [];

        for (let x of data) {
            titles.push(x.name)
            values.push(x.value)
        }
        var spirit = 'image://';

        var maxData = 20;


        myChart.setOption(
        option = {
            tooltip: {
            },
            xAxis: {
                max: maxData,
                splitLine: {show: false},
                offset: 1,
                axisLine: {
                    lineStyle: {
                        color: '#999'
                    }
                },
                axisLabel: {
                    margin: 1
                }
            },
            yAxis: {
                data: titles,
                inverse: true,
                axisTick: {show: false},
                axisLine: {show: false},
                axisLabel: {
                    margin: 1,
                    color: '#999',
                    fontSize: 10
                }
            },
            grid: {
                top: 'center',
                height: 600,
                left: 70,
                right: 100
            },
            series: [{
                // current data
                type: 'pictorialBar',
                symbol: spirit,
                symbolRepeat: 'fixed',
                symbolMargin: '5%',
                symbolClip: true,
                symbolSize: 30,
                symbolBoundingData: maxData,
                data: values,
                markLine: {
                    symbol: 'none',
                    label: {
                        formatter: 'max: {c}',
                        position: 'start'
                    },
                    lineStyle: {
                        color: 'green',
                        type: 'dotted',
                        opacity: 0.2,
                        width: 2
                    },
                    data: [{
                        type: 'max'
                    }]
                },
                z: 10
            }, {
                // full data
                type: 'pictorialBar',
                itemStyle: {
                    normal: {
                        opacity: 0.2
                    }
                },
                label: {
                    show: true,
                    formatter: function (params) {
                        return (params.value / maxData * 100).toFixed(1) + ' %';
                    },
                    position: 'right',
                    offset: [10, 0],
                    color: 'green',
                    fontSize: 18
                },
                animationDuration: 0,
                symbolRepeat: 'fixed',
                symbolMargin: '5%',
                symbol: spirit,
                symbolSize: 30,
                symbolBoundingData: maxData,
                data: values,
                z: 5
            }]
        }
        )
    });
        // 使用刚指定的配置项和数据显示图表。
        /*myChart.setOption(
            option = {
                color: ['#db8091'],
                title: {
                    left: 'center',
                    text: '产品产品市场价排行',
                },
                xAxis: {
                    type: 'category',
                    data: titles,
                    axisLabel: {
                        rotate:70
                    }
                },
                yAxis: {
                    type: 'value'
                },
                series: [{
                    data: values,
                    type: 'bar'
                }]
            }
        )
    });*/

</script>

</html>